package com.gxc.my;

import com.gxc.utils.NowDate;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * 切面类.
 *
 * @author 宫新程
 * @since 2018/12/14 12:35 PM
 */
@Aspect
@Component
public class MyAspect {

  @Pointcut("execution(* com.gxc.my.MyService.*(..))")
  public void myPointCut() {}

  // @After("MyAspect.myPointCut()")
  public void after() {
    System.out.println("执行完毕：" + System.currentTimeMillis());
  }

  @Around("MyAspect.myPointCut()")
  public void around(ProceedingJoinPoint joinPoint) throws Throwable {
    System.out.println("around前：" + NowDate.getNowDate());
    for (int i = 0; i < 100; i++) {}
    joinPoint.proceed();
    System.out.println("around后：" + NowDate.getNowDate());
  }
}
